package com.ly.base.chapter02.AAAFuncCitation;
import java.util.stream.Stream;


/**
 * 方法引用： 2、非静态方法引用
 */
public class FuncCitationBNoStatic {
    public static void main(String[] args) {
     /*
            需求：挑选出所有男性学生
         */
        Stream.of(
                new Student("张无忌", 17, "男"),
                new Student("周芷若", 20, "女"),
                new Student("宋青书", 26, "男")
        )
                .filter(Student::isMale)//非静态方法引用
                .forEach(Student::printStu);


    }

    record Student(String name,Integer age,String sex){
        public boolean isMale(){
          return this.sex.equals("男");
            /**
             *   Student::isMale
             *   (stu) -> stu.isMale()
             */
        }

        public void printStu(){
            System.out.println(this);
            /**
             * Stuent::printStu
             * (stu) -> stu.printStu()
             */
        }
    }

}

